package com.zb.file.controller;

import com.zb.annotation.SystemLog;
import com.zb.constant.OperationLogModuleType;
import com.zb.file.service.FileService;
import com.zb.result.Result;
import com.zb.utils.TokenUtil;
import com.zb.yaml.FilePath;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author WEN
 * @Date 2023/8/18 0018
 **/
@Api(tags = "logo类接口")
@RestController
@RequestMapping("/logo")
public class LogoController {
    @Resource
    private FileService fileService;

    @ApiOperation("上传Logo")
    @PostMapping("/logoUpload")
    public Result logoUpload(HttpServletRequest request, @ApiParam(value = "文件，以二进制方式上传（form-data），只能单个上传") MultipartFile file) {
        String logoCode = TokenUtil.getCustAccLogoCode(request);
        return Result.success("logo上传成功！").data("row",
                fileService.logoUpload(FilePath.annexUploadPath(),
                        FilePath.domain() + FilePath.annexVisitPath(),
                        logoCode, file));
    }

}
